package novel.spider.enums;

//已经被支持的小说网站枚举
public enum NovelSiteEnum {
	顶点小说(1, "x23us.com"), 笔趣阁(2, "xs.la"), zzu(3, "zzuisa.cn"),;
	private Integer id;
	private String url;

	private NovelSiteEnum(Integer id, String url) {
		this.id = id;
		this.url = url;
	}

	public Integer getId() {
		return id;
	}

	public String getUrl() {
		return url;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public static NovelSiteEnum getEnumById(Integer id) {
		switch (id) {
		case 1:
			return 顶点小说;
		case 2:
			return 笔趣阁;
		case 3:
			return zzu;
		default:
			throw new RuntimeException("id=" + id + "是不被支持的小说网站");
		}
	}

	public static NovelSiteEnum getEnumByUrl(String url) {
		// x23us.com xs.la
		for (NovelSiteEnum novelSiteEnum : values()) {
			if (url.contains(novelSiteEnum.url)) {
				return novelSiteEnum;
			}
		}
		throw new RuntimeException("url:" + url + "是不被支持的小说网站");
	}

}
